<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@include file="../common/head.jsp"%>
<%@taglib prefix="form" uri="http://www.springframework.org/tags/form" %>

<div class="right">
        <div class="location">
            <strong>你现在所在的位置是:</strong>
            <span>供应商管理页面 >> 供应商添加页面</span>
        </div>
    <script>
        //保存
        function baoCun(){
            var flag = false;
            var proCode = $("#proCode").val();
            var proName = $("#proName").val();
            var proContact = $("#proContact").val();
            var proPhone = $("#proPhone").val();
            if (proCode == "" ||proName == "" ||proContact == "" || proPhone == ""){
                $("#hint").text("请完善订单信息再进行保存!")
                return flag;
            }
            $.ajax({
                type:"post",//请求类型
                url:"doProCode",//请求的url
                data:{
                    proCode:$("#proCode").val()
                }, dataType:"json",//ajax接口（请求url）返回的数据类型
                async:false,//是否位同步,true(默认值):异步false:同步
                success:function(data){//data：返回数据（json对象）
                    if (data == "1") {
                        $("#proCodeTiShi").text("此编码已存在!");
                        $("#hint").text("");
                        flag = false;
                    }else {
                        flag = true;
                    }
                },
            });
            return flag;
        }
    </script>
        <div class="providerAdd">
           <form:form modelAttribute="provider" id="providerForm" name="providerForm" method="post" action="doAdd" onsubmit="return baoCun()">
			<input type="hidden" name="method" value="add">
                <!--div的class 为error是验证错误，ok是验证成功-->
                <div class="">
                    <label for="proCode">供应商编码：</label>
                    <input type="text" name="proCode" id="proCode" value=""> 
					<!-- 放置提示信息 -->
					<font color="red" id="proCodeTiShi"></font>
					<font color="red"><form:errors path="proCode"/></font>
                </div>
                <div>
                    <label for="proName">供应商名称：</label>
                   <input type="text" name="proName" id="proName" value=""> 
					<font color="red"></font>
					<font color="red"><form:errors path="proName"/></font>
                </div>
                <div>
                    <label for="proContact">联系人：</label>
                    <input type="text" name="proContact" id="proContact" value=""> 
					<font color="red"></font>
                    <font color="red"><form:errors path="proContact"/></font>
                </div>
                <div>
                    <label for="proPhone">联系电话：</label>
                    <input type="text" name="proPhone" id="proPhone" value=""> 
					<font color="red"></font>
					<font color="red"><form:errors path="proPhone"/></font>
                </div>
                <div>
                    <label for="proAddress">联系地址：</label>
                    <input type="text" name="proAddress" id="proAddress" value="">
                    <font color="red"></font>
                </div>
                <div>
                    <label for="proFax">传真：</label>
                    <input type="text" name="proFax" id="proFax" value="">
                    <font color="red"></font>
                </div>
                <div>
                    <label for="proDesc">描述：</label>
                    <input type="text" name="proDesc" id="proDesc" value="">
                    <font id="hint" color="red"></font>
                </div>
                <div class="providerAddBtn">
                    <input type="submit" name="add" id="add" value="保存">
					<input type="button" id="back" name="back" value="返回" >
                </div>
            </form:form>
     </div>
</div>
</section>
<%@include file="../common/foot.jsp" %>
<script type="text/javascript" src="${pageContext.request.contextPath }/js/provideradd.js"></script>
